﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace InControl
{
    public partial class INV_home_form : Form
    {     
        public INV_home_form()
        {
            InitializeComponent();
        }

      
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            if (((INV_MDIParent)this.MdiParent).appDriver.pid != -1)
            {
                ((INV_MDIParent)this.MdiParent).OpenForm(typeof(INV_office_form));
            }
            else
                ((INV_MDIParent)this.MdiParent).OpenForm(typeof(login));
        }

        private void OfSp_Click(object sender, EventArgs e)
        {
            this.pictureBox2_Click(sender, e);
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (((INV_MDIParent)this.MdiParent).appDriver.pid != -1)
                ((INV_MDIParent)this.MdiParent).OpenForm(typeof(INV_initpeople_form));
            else
                ((INV_MDIParent)this.MdiParent).OpenForm(typeof(login));
        }

        private void label1_Click(object sender, EventArgs e)
        {
            pictureBox1_Click(sender, e);
        }

        private void Welcome_1_Label_Click(object sender, EventArgs e)
        {
            if (((INV_MDIParent)this.MdiParent).appDriver.pid == -1)
                ((INV_MDIParent)this.MdiParent).OpenForm(typeof(login));
        }

        private void pictureBox3_Click(object sender, EventArgs e)
        {

        }

        private void Main_Panel_Paint(object sender, PaintEventArgs e)
        {

        }

        private void INV_home_form_Load(object sender, EventArgs e)
        {
            button1.Visible = false;

            if (((INV_MDIParent)this.MdiParent).appDriver.pid != -1)
            {
                Welcome_1_Label.Text = ((INV_MDIParent)this.MdiParent).appDriver.getfullName() + ",";
                button1.Visible = true;
            }
        }

        private void ClSp_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ((INV_MDIParent)this.MdiParent).appDriver.pid = -1;
                ((INV_MDIParent)this.MdiParent).appDriver.CloseConnection();
                ((INV_MDIParent)this.MdiParent).OpenForm(typeof(login));
            }
            catch (Exception ex)
            {
                Error_form ef = new Error_form();
                ef.richTextBox1.Text = ex.Message;
                ef.ShowDialog(this);
            }
        }
    }
}
